package com.baiyue.controller;


import com.baiyue.annotation.SystemLog;
import com.baiyue.enums.LogType;
import com.baiyue.model.commodityConsumption.CommodityConsumptionDataRequest;
import com.baiyue.model.commodityConsumption.CommodityConsumptionDataResponse;
import com.baiyue.result.Result;
import com.baiyue.service.CommodityConsumptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @author 伍波
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/api/commodityConsumption")
public class CommodityConsumptionController {
    @Autowired
    private CommodityConsumptionService commodityConsumptionService;

    @SystemLog(description = "新增商品消费",type = LogType.NEWADD)
    @PostMapping("/addList")
    public Result<Boolean> insertList(@RequestBody List<CommodityConsumptionDataRequest> requests){
        commodityConsumptionService.insertList(requests);
        return Result.success(true);
    }

    @PostMapping("/byUuid")
    public Result<List<CommodityConsumptionDataResponse>> findByUuid(@RequestBody CommodityConsumptionDataRequest request){
        return Result.success(commodityConsumptionService.findByUuid(request));
    }

    @PostMapping("/delete")
    public Result<Boolean> deleteById(@RequestBody CommodityConsumptionDataRequest request){
        commodityConsumptionService.deleteById(request);
        return Result.success(true);
    }
}

